package com.tms.app.tms.adapter;

import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tms.app.tms.R;
import com.tms.app.tms.bean.Msg;
import com.tms.app.tms.bean.TestBean;
import com.tms.app.tms.utils.TimeUtil;

import java.util.List;

/**
 * Created by happy on 2017/8/26.
 */

public class OrderChildAdapter extends BaseQuickAdapter<Msg, BaseViewHolder> {
    public OrderChildAdapter() {
        super(R.layout.item_home_msg_task);
    }



    @Override
    protected void convert(BaseViewHolder helper, Msg item) {

        helper.setText(R.id.item_msg_time, TimeUtil.getTimeFormat(item.getPublishTime()));
        helper.setText(R.id.item_order_no,item.getAllotPlanNo());

        helper.setText(R.id.item_msg_content,item.getTitle());
        helper.setText(R.id.item_msg_content2,item.getContent());
        if (item.getReadStatus()==0){
            helper.getView(R.id.item_msg_num).setVisibility(View.VISIBLE);
        }else {
            helper.getView(R.id.item_msg_num).setVisibility(View.INVISIBLE);
        }
        setBusiType(helper,item.getBusiType());
    }

    private void setBusiType(BaseViewHolder helper,String ... type){
        TextView textView1=helper.getView(R.id.text_fabu_type1);
        TextView textView2=helper.getView(R.id.text_fabu_type2);
        TextView textView3=helper.getView(R.id.text_fabu_type3);

        textView1.setVisibility(View.GONE);
        textView2.setVisibility(View.GONE);
        textView3.setVisibility(View.GONE);

        for (String str : type) {
            String[] busiTypes=str.split(",");
            for (String type1 : busiTypes) {
                switch (type1){
                    case "0":
                        textView1.setVisibility(View.VISIBLE);
                        break;
                    case "1":
                        textView2.setVisibility(View.VISIBLE);
                        break;
                    case "2":
                        textView3.setVisibility(View.VISIBLE);
                        break;
                }
            }

        }

    }
}
